<?php
/**
 * Autor:   Miguel A. Zilli
 * Email:   miguelzilli@gmail.com
 */

class Subsidio extends AppModel {
    var $name = 'Subsidio';
    var $useTable = 'subsidios';
    var $primaryKey = 'id';
    var $displayField = 'fch_ent_subs';
    var $recursive = 0;
    var $order=array(
        'Subsidio.fch_ent_subs'=>'ASC'
    );

    var $validate = array(
        'monto_subs'=>array(
            array('rule'=>'money','message'=>'Solo se permiten números.','allowEmpty' => false)
        )
    );

    var $belongsTo = array(
        'Entidad' => array(
            'className' => 'Entidad',
            'foreignKey' => 'entidad_id'
        ),
        'Revision' => array(
            'className' => 'Revision',
            'foreignKey' => 'revision_id'
        )
    );

    public function beforeSave(){
        if(!empty($this->data['Subsidio'])){
            foreach($this->data['Subsidio'] as $campo=>$valor){
                $this->data['Subsidio'][$campo]=strtoupper($valor);
            }
        }
        return true;
    }
}
?>